﻿Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Drawing
Imports System.Windows.Forms
Imports System.Drawing.Drawing2D

<Designer(GetType(DDPanelDesigner)), DesignTimeVisibleAttribute(True)> _
Public Class DDPanel
    Inherits System.Windows.Forms.UserControl

    Private mstrHeaderText As String = "DDPanel"
    Private mintHeight As Integer

    Private mIcon As Icon
    Private mExpanded As Boolean = True
    Private mHighlighted As Boolean = False
    Private mDisableOnCollapse As Boolean = True

    Private mControlState As New Hashtable

    'MY STUFF
    Public Event HeaderTextChanged(sender As DDPanel, e As System.EventArgs)
    Public FirstPanel As Boolean = False
    Public LastPanel As Boolean = False
    Public ExpandOnClick As Boolean = True
    Private IsBottomAnchorOn As Boolean = False

#Region " Vom Windows Form Designer generierter Code "

    Public Sub New()
        MyBase.New()

        ' Dieser Aufruf ist für den Windows Form-Designer erforderlich.
        InitializeComponent()

        ' Initialisierungen nach dem Aufruf InitializeComponent() hinzufügen
        SetStyle(ControlStyles.ResizeRedraw, True)
        SetStyle(ControlStyles.AllPaintingInWmPaint, True)
        SetStyle(ControlStyles.UserPaint, True)
        SetStyle(ControlStyles.DoubleBuffer, True)
        SetStyle(ControlStyles.SupportsTransparentBackColor, True)
        SetStyle(ControlStyles.ContainerControl, True)

        MyBase.BackColor = Color.Transparent
    End Sub

    Public Sub New(ContainerCollection As DDPanelCollection, ContainerPanel As DDPanelStack, HeaderText As String)
        Me.New()
        Me.mstrHeaderText = HeaderText
    End Sub

    ' UserControl1 überschreibt den Löschvorgang zur Bereinigung der Komponentenliste.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    ' Für Windows Form-Designer erforderlich
    Private components As System.ComponentModel.IContainer

    'HINWEIS: Die folgende Prozedur ist für den Windows Form-Designer erforderlich
    'Sie kann mit dem Windows Form-Designer modifiziert werden.
    'Verwenden Sie nicht den Code-Editor zur Bearbeitung.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.SuspendLayout()
        '
        'DDPanel
        '
        Me.Name = "DDPanel"
        Me.Padding = New System.Windows.Forms.Padding(4, 44, 4, 4)
        Me.ResumeLayout(False)

    End Sub

#End Region

#Region "Public Properties"
    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' sets the icon that is displayed in the title bar
    ''' </summary>
    ''' <value>Icon</value>
    ''' <remarks>
    ''' 
    ''' </remarks>
    ''' <history>
    ''' 	[Mike]	14.03.2004	Created
    ''' </history>
    ''' -----------------------------------------------------------------------------
    <Description("Icon"), _
    Category("Appearance"), _
    Localizable(True), _
    DefaultValue(GetType(Icon), "")> _
    Public Property Icon() As Icon
        Get
            Return mIcon
        End Get
        Set(ByVal value As Icon)
            mIcon = value
            Me.Invalidate()
        End Set
    End Property

    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' Shows the taskbox expanded or collapsed
    ''' </summary>
    ''' <value>Boolean. True if the taskbox is expanded</value>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' 	[Mike]	14.03.2004	Created
    '''     [Mike]  25.04.2004  added ChangeHeight because of bug when initializing the control
    ''' </history>
    ''' -----------------------------------------------------------------------------
    <Description("Shows the toolbox expanded or collapsed"), _
    Category("Appearance"), _
    DefaultValue(True)> _
    Public Property IsExpanded() As Boolean
        Get
            Return mExpanded
        End Get
        Set(ByVal value As Boolean)
            mExpanded = value
            ChangeHeight()
            Me.Invalidate()
        End Set
    End Property

    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' disables all controls inside the task box if the task box is collapsed
    ''' </summary>
    ''' <value></value>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' 	[Mike]	17.05.2005	Created
    ''' </history>
    ''' -----------------------------------------------------------------------------
    <Description("disables all controls inside the task box if the task box is collapsed"), _
     Category("Appearance"), _
     DefaultValue(True)> _
    Public Property DisableOnCollapse() As Boolean
        Get
            Return mDisableOnCollapse
        End Get
        Set(ByVal value As Boolean)
            mDisableOnCollapse = value
        End Set
    End Property

    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' Shows the taskbox highlighted (selected)
    ''' </summary>
    ''' <value>Boolean.</value>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' 	[Mike]	14.03.2004	Created
    ''' </history>
    ''' -----------------------------------------------------------------------------
    <Description("Shows the toolbox highlighted (selected)"), _
    Category("Appearance"), _
    DefaultValue(False)> _
    Public Property Highlighted() As Boolean
        Get
            Return mHighlighted
        End Get
        Set(ByVal value As Boolean)
            mHighlighted = value
        End Set
    End Property

    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' Caption text.
    ''' </summary>
    ''' <value>String</value>
    ''' <remarks>
    ''' the text that is displayed in the title region of the control
    ''' </remarks>
    ''' <history>
    ''' 	[Mike]	14.03.2004	Created
    ''' </history>
    ''' -----------------------------------------------------------------------------
    <Description("Caption text."), _
    DefaultValue("Title"), _
    Category("Appearance"), _
    Browsable(True), _
    Localizable(True)> _
    Public Property HeaderText() As String
        Get
            Return mstrHeaderText
        End Get
        Set(ByVal value As String)
            mstrHeaderText = value
            Me.Invalidate()
            RaiseEvent HeaderTextChanged(Me, New EventArgs)
        End Set
    End Property


    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' returns the usable region as RectangleF
    ''' </summary>
    ''' <value>Rectangle</value>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' 	[Mike]	14.03.2004	Created
    ''' </history>
    ''' -----------------------------------------------------------------------------
    <Description("returns the usable region as Rectangle"), _
    Browsable(False)> _
    Friend ReadOnly Property WorkspaceRect() As Rectangle
        Get
            Return Helpers.CheckedRectangle(3, 41, Me.Width - 7, Me.Height - 40 - 4)
        End Get
    End Property

#End Region

#Region "Custom Painting"
    Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
        e.Graphics.SmoothingMode = SmoothingMode.HighQuality

        Dim lrectHeader As RectangleF = Helpers.CheckedRectangleF(0, 0, Me.Width, 24)
        Dim lrectHeaderText As RectangleF
        Dim lrectBody As RectangleF = Helpers.CheckedRectangleF(0, 24, Me.Width, Me.Height - 24)
        Dim lrectAll As RectangleF = Helpers.CheckedRectangleF(0, 0, Me.Width, Me.Height)

        Dim gp As New GraphicsPath
        Dim lbrushHeader As LinearGradientBrush = Nothing
        Dim lpenBorder As New Pen(SystemBrushes.ActiveBorder, 1)
        Dim stringFmt As New StringFormat

        stringFmt.Alignment = StringAlignment.Center
        stringFmt.LineAlignment = StringAlignment.Center
        stringFmt.Trimming = StringTrimming.EllipsisCharacter
        stringFmt.FormatFlags = StringFormatFlags.NoWrap

        lpenBorder.Alignment = PenAlignment.Inset

        'body
        If mExpanded Then
            gp = Paths.RoundedRect(lrectAll, 5, 1, Corner.All)
            e.Graphics.FillPath(New SolidBrush(SystemColors.InactiveBorder), gp)
        End If

        'Header background
        If mExpanded Then
            gp = Paths.RoundedRect(lrectHeader, 5, 1, Corner.TopLeft Or Corner.TopRight)
        Else
            gp = Paths.RoundedRect(lrectHeader, 5, 1, Corner.All)
        End If

        If mHighlighted Then
            lbrushHeader = New LinearGradientBrush(lrectHeader, _
                                                    Color.DarkGoldenrod, _
                                                    Color.DarkKhaki, _
                                                    LinearGradientMode.Horizontal)
        Else
            lbrushHeader = New LinearGradientBrush(lrectHeader, _
                                                    Color.DarkKhaki, _
                                                    Color.Khaki, _
                                                    LinearGradientMode.Horizontal)
        End If
        e.Graphics.FillPath(lbrushHeader, gp)

        ' Draw the outline around the work area
        If mExpanded Then
            gp = Paths.RoundedRect(lrectAll, 5, 1, Corner.All)
        End If
        e.Graphics.DrawPath(lpenBorder, gp)

        'draw icon
        If Not mIcon Is Nothing Then
            e.Graphics.DrawIcon(New Icon(mIcon, New Size(32, 32)), New Rectangle(4, 8, 32, 32))
            lrectHeaderText = Helpers.CheckedRectangleF(40, 0, Me.Width - 64, 24)
        Else
            lrectHeaderText = Helpers.CheckedRectangleF(8, 0, Me.Width - 24, 24)
        End If

        'up down icon
        If Me.mExpanded Then
            e.Graphics.DrawImage(My.Resources.Icon_Up_Normal, Helpers.CheckedRectangle(Me.Width - 24, 2, 21, 21))
        Else
            e.Graphics.DrawImage(My.Resources.Icon_Down_Normal, Helpers.CheckedRectangle(Me.Width - 24, 2, 21, 21))
        End If

        ' Caption text.
        If mHighlighted Then
            e.Graphics.DrawString(mstrHeaderText, Me.Font, SystemBrushes.HighlightText, lrectHeaderText, stringFmt)
        Else
            e.Graphics.DrawString(mstrHeaderText, Me.Font, SystemBrushes.ControlText, lrectHeaderText, stringFmt)
        End If

        'dispose all objects
        lrectHeader = Nothing
        lrectHeaderText = Nothing
        lrectBody = Nothing
        lrectAll = Nothing
        gp.Dispose()
        lbrushHeader.Dispose()
        lpenBorder.Dispose()
        stringFmt.Dispose()

        'MyBase.OnPaint(e)
    End Sub
#End Region

#Region "Mouse Actions"
    Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
        ' Change cursor to hand when over caption area.
        Dim bChanged As Boolean = False

        If e.Y <= 32 Then
            System.Windows.Forms.Cursor.Current = Cursors.Hand
            If mHighlighted = False Then
                mHighlighted = True
                bChanged = True
            End If
        Else
            System.Windows.Forms.Cursor.Current = Cursors.Default
            If mHighlighted = True Then
                mHighlighted = False
                bChanged = True
            End If
        End If

        If bChanged Then
            Me.Invalidate()
        End If

    End Sub

    Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
        If ExpandOnClick Then
            ' Don't do anything if did not click on caption.
            If e.Y > 32 Then
                Return
            End If

            ' Toggle expanded flag.
            mExpanded = Not mExpanded

            ' Expand or collapse the control based on its current state
            ChangeHeight()
            Me.Refresh()
        End If
    End Sub

    Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
        If mHighlighted Then
            mHighlighted = False
            Me.Invalidate()
        End If
    End Sub
#End Region

#Region "events"
    Public Delegate Sub CollapsedHandler(ByVal sender As Object, ByVal e As EventArgs)
    Public Event Collapsed As CollapsedHandler
    Protected Overridable Sub OnCollapsed(ByVal e As EventArgs)
        RaiseEvent Collapsed(Me, e)
    End Sub

    Public Delegate Sub ExpandedHandler(ByVal sender As Object, ByVal e As EventArgs)
    Public Event Expanded As ExpandedHandler
    Protected Overridable Sub OnExpanded(ByVal e As EventArgs)
        RaiseEvent Expanded(Me, e)
    End Sub
#End Region

    Protected Overrides Sub OnResize(e As System.EventArgs)
        MyBase.OnResize(e)
        Me.mintHeight = Me.Height
    End Sub

    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' Changes the height of the control according to its state
    ''' </summary>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' 	[Mike]	10.08.2004	Created
    ''' </history>
    ''' -----------------------------------------------------------------------------
    Private Sub ChangeHeight()
        If Not mExpanded Then
            ' Remember height so we can restore it later.
            'mintHeight = Me.Height

            ' Set the new height and let others know we have been collapsed
            While Me.Height > 25
                Me.Height -= 15
                Application.DoEvents()
                Threading.Thread.Sleep(10)
            End While
            Me.Height = 25
            OnCollapsed(New EventArgs)
            If mDisableOnCollapse Then HideChildControls()
        Else
            While Me.Height < mintHeight
                Me.Height += 15
                Application.DoEvents()
                Threading.Thread.Sleep(10)
            End While
            Me.Height = mintHeight
            OnExpanded(New EventArgs)
            If mDisableOnCollapse Then ShowChildControls()
        End If
    End Sub

    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' expands the taskbox
    ''' </summary>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' 	[Mike]	14.03.2004	Created
    ''' </history>
    ''' -----------------------------------------------------------------------------
    Public Sub Expand()
        If Not mExpanded Then
            mExpanded = True
            ChangeHeight()
            'TURN ON BOTTOM ANCHORING IF IT WAS TURNED OFF PREVIOUSLY
            'If ((Me.Anchor AndAlso AnchorStyles.Bottom) = AnchorStyles.Bottom) Then
            '    Me.IsBottomAnchorOn = True

            'End If
        End If
    End Sub

    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' collapses the taskbox to a title bar
    ''' </summary>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' 	[Mike]	14.03.2004	Created
    ''' </history>
    ''' -----------------------------------------------------------------------------
    Public Sub Collapse()
        If mExpanded Then
            mExpanded = False
            ChangeHeight()
            'TEMPORARILY REMOVE BOTTOM ANCHORING IF IT IS ON
            'If ((Me.Anchor AndAlso AnchorStyles.Bottom) = AnchorStyles.Bottom) Then
            '    Me.IsBottomAnchorOn = True

            'End If

        End If
    End Sub

    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' hides all child controls on the taskbox
    ''' </summary>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' 	[Mike]	10.08.2004	Created
    ''' </history>
    ''' -----------------------------------------------------------------------------
    Private Sub HideChildControls()
        mControlState.Clear()
        For Each child As Control In Me.Controls
            mControlState.Add(child.Name, child.Visible)
            child.Visible = False
        Next
    End Sub

    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' shows all childControls that were initialy visible
    ''' </summary>
    ''' <remarks>
    ''' </remarks>
    ''' <history>
    ''' 	[Mike]	10.08.2004	Created
    ''' </history>
    ''' -----------------------------------------------------------------------------
    Private Sub ShowChildControls()
        For Each child As Control In Me.Controls
            If mControlState.ContainsKey(child.Name) Then
                child.Visible = CBool(mControlState.Item(child.Name))
            Else
                child.Visible = True
            End If
        Next
    End Sub


End Class

''' <summary>
''' this class adds visual clues to the design-time experience with the DDPanel class
''' It provides a border and a workspace "clue".
''' You also need this class to add child controls to the user control
''' </summary>
''' <remarks></remarks>
Public Class DDPanelDesigner
    Inherits BaseDesigner

    Private m_Control As DDPanel

    Public Sub New()
        MyBase.New()
    End Sub

    Public Overrides Sub Initialize(ByVal component As System.ComponentModel.IComponent)
        MyBase.Initialize(component)
        m_Control = CType(Me.Control, DDPanel)
    End Sub

    Protected Overrides Sub OnPaintAdornments(ByVal pe As Windows.Forms.PaintEventArgs)
        MyBase.OnPaintAdornments(pe)
        pe.Graphics.DrawRectangle(WorkspacePen, m_Control.WorkspaceRect)
    End Sub

End Class

''' <summary>
''' Base Class for all control designers. This class will allow the display of design
''' time hints and graphics for all controls that use this (or an inherited) designer.
''' 
''' It will also allow the display of "Verbs". These verbs are displayed as link in the 
''' property dialog of VS and can be used to execute code.
''' </summary>
''' <remarks></remarks>
Public MustInherit Class BaseDesigner
    Inherits System.Windows.Forms.Design.ParentControlDesigner

    Private m_BorderPen As New Drawing.Pen(Drawing.SystemColors.ControlDark)
    Private m_WorkspacePen As New Drawing.Pen(Drawing.SystemColors.ControlLight)
    Private m_Font As New Drawing.Font("Arial", 6, Drawing.FontStyle.Regular)
    Private m_Format As New Drawing.StringFormat(Drawing.StringFormatFlags.LineLimit)
    Private m_Verbs As New DesignerVerbCollection
    Private m_mouseover As Boolean = False

    Private Const compName As String = "steepvalley.net"

    Protected Sub New()
        m_WorkspacePen.DashStyle = Drawing.Drawing2D.DashStyle.Dot
        m_BorderPen.DashStyle = Drawing.Drawing2D.DashStyle.Dash
        m_Format.Trimming = Drawing.StringTrimming.EllipsisCharacter
        m_Verbs.Add(New DesignerVerb("About", New EventHandler(AddressOf AboutEvent)))
    End Sub

    Protected Overrides Sub OnMouseEnter()
        Me.m_mouseover = True
        Me.Control.Refresh()
    End Sub

    Protected Overrides Sub OnMouseLeave()
        Me.m_mouseover = False
        Me.Control.Refresh()
    End Sub

    Protected Overrides Sub OnPaintAdornments(ByVal pe As System.Windows.Forms.PaintEventArgs)
        MyBase.OnPaintAdornments(pe)

        'pe.Graphics.CompositingQuality = Drawing.Drawing2D.CompositingQuality.HighQuality
        ''place the text in the left bottom 
        'Dim _s As Drawing.SizeF = pe.Graphics.MeasureString(compName, m_Font, Me.Control.Width, m_Format)
        'If Me.MouseOver = True Then
        '    pe.Graphics.FillRectangle(New Drawing.SolidBrush(Drawing.Color.White), 0, Me.Control.Height - _s.Height, _s.Width, _s.Height)
        '    pe.Graphics.DrawRectangle(New Drawing.Pen(Drawing.Color.Black), 0, Me.Control.Height - _s.Height, _s.Width, _s.Height)
        '    pe.Graphics.DrawString("steepvalley.net", m_Font, New Drawing.SolidBrush(Drawing.Color.Black), Helpers.CheckedRectangleF(0, Me.Control.Height - _s.Height, _s.Width, _s.Height), m_Format)
        'End If
    End Sub

#Region "protected properties"
    Protected Property BorderPen() As Drawing.Pen
        Get
            Return m_BorderPen
        End Get
        Set(ByVal Value As Drawing.Pen)
            m_BorderPen = Value
        End Set
    End Property

    Protected Property WorkspacePen() As Drawing.Pen
        Get
            Return m_WorkspacePen
        End Get
        Set(ByVal Value As Drawing.Pen)
            m_WorkspacePen = Value
        End Set
    End Property

    Protected Property Font() As Drawing.Font
        Get
            Return m_Font
        End Get
        Set(ByVal Value As Drawing.Font)
            m_Font = Value
        End Set
    End Property

    Protected Property MouseOver() As Boolean
        Get
            Return m_mouseover
        End Get
        Set(ByVal Value As Boolean)
            m_mouseover = Value
        End Set
    End Property

    Protected ReadOnly Property CompanyName() As String
        Get
            Return compName
        End Get
    End Property
#End Region

#Region "managing verbs"
    Public Overrides ReadOnly Property Verbs() As System.ComponentModel.Design.DesignerVerbCollection
        Get
            Return m_Verbs
        End Get
    End Property

    Protected Sub AboutEvent(ByVal sender As Object, ByVal e As EventArgs)
        ''show about dialog
        'Dim d As New About
        'd.ShowDialog()
        'd.Dispose()
    End Sub

    Protected Sub AddVerb(ByVal verb As DesignerVerb)
        m_Verbs.Add(verb)
    End Sub

    Protected Sub AddVerb(ByVal text As String, ByVal handler As System.EventHandler)
        m_Verbs.Add(New DesignerVerb(text, handler))
    End Sub
#End Region

End Class

'#Region "MY CORRUPT DDPANEL"
'Imports System.Drawing
'Imports System.Windows.Forms
'Imports System.Drawing.Drawing2D

'<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
'Public Class DDPanel
'    Inherits System.Windows.Forms.Panel

'#Region "Designer Generated Code"
'    'UserControl overrides dispose to clean up the component list.
'    <System.Diagnostics.DebuggerNonUserCode()> _
'    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
'        Try
'            If disposing AndAlso components IsNot Nothing Then
'                components.Dispose()
'            End If
'        Finally
'            MyBase.Dispose(disposing)
'        End Try
'    End Sub

'    'Required by the Windows Form Designer
'    Private WithEvents components As System.Windows.Forms.Panel

'    'NOTE: The following procedure is required by the Windows Form Designer
'    'It can be modified using the Windows Form Designer.  
'    'Do not modify it using the code editor.
'    <System.Diagnostics.DebuggerStepThrough()> _
'    Private Sub InitializeComponent()
'        Me.components = New System.Windows.Forms.Panel()
'        Me.SuspendLayout()
'        '
'        'PanelX
'        '
'        Me.components.Name = "PanelX"
'        Me.components.TabIndex = 0
'        Me.ResumeLayout(False)
'    End Sub
'#End Region

'#Region "Declarations"

'    Private iContainerCollection As DDPanelCollection = Nothing
'    Private iContainerPanel As DDPanelStack = Nothing

'    Private WithEvents iHeader_Panel As New Panel
'    Private WithEvents iContents_Panel As New Panel

'    Private iAnimationDelay As Integer = 10

'    Private iAnimationSteps As Integer = 10

'    Private iExpandOnClick As Boolean = True
'    Public Property ExpandOnClick As Boolean
'        Get
'            Return Me.iExpandOnClick
'        End Get
'        Set(value As Boolean)
'            Me.iExpandOnClick = value
'            If Me.iExpandOnClick = False AndAlso Me.iExpanded = False Then
'                Me.Expand()
'            End If
'        End Set
'    End Property
'    Private iFirstPanel As Boolean = False
'    Public Property FirstPanel As Boolean
'        Get
'            Return Me.iFirstPanel
'        End Get
'        Set(value As Boolean)
'            Me.iFirstPanel = value
'        End Set
'    End Property
'    Private iLastPanel As Boolean = False
'    Public Property LastPanel As Boolean
'        Get
'            Return Me.iLastPanel
'        End Get
'        Set(value As Boolean)
'            Me.iLastPanel = value
'        End Set
'    End Property
'    Private iExpanded As Boolean = True
'    Public Property Expanded As Boolean
'        Get
'            Return Me.iExpanded
'        End Get
'        Set(value As Boolean)
'            If (Me.iExpanded = True) AndAlso (value = False) Then
'                Me.iExpanded = value
'                Me.Collapse()
'            Else
'                Me.iExpanded = value
'                Me.Expand()
'            End If
'        End Set
'    End Property
'    Private iExpandedHeight As Integer = Me.Size.Height
'    Public Property ExpandedHeight As Integer
'        Get
'            Return Me.iExpandedHeight
'        End Get
'        Set(value As Integer)
'            Me.iExpandedHeight = value
'        End Set
'    End Property

'    Private iExpanding As Boolean = False
'    Public ReadOnly Property Expanding As Boolean
'        Get
'            Return Me.iExpanding
'        End Get
'    End Property
'    Private iCollapsing As Boolean = False
'    Public ReadOnly Property Collapsing As Boolean
'        Get
'            Return Me.iCollapsing
'        End Get
'    End Property

'    Private iIconCollapse As Image = My.Resources.Icon_Up_Normal
'    Public Property IconCollapse As Image
'        Get
'            Return Me.iIconCollapse
'        End Get
'        Set(value As Image)
'            Me.iIconCollapse = value
'            Me.iHeader_Panel.Invalidate()
'        End Set
'    End Property
'    Private iIconExpand As Image = My.Resources.Icon_Down_Normal
'    Public Property IconExpand As Image
'        Get
'            Return Me.iIconExpand
'        End Get
'        Set(value As Image)
'            Me.iIconExpand = value
'            Me.iHeader_Panel.Invalidate()
'        End Set
'    End Property
'    Private iContainerBackColor As Color = SystemColors.GradientInactiveCaption
'    Public Property ContainerBackColor As Color
'        Get
'            Return Me.iContainerBackColor
'        End Get
'        Set(value As Color)
'            Me.iContainerBackColor = value
'            Me.iHeader_Panel.Invalidate()
'            Me.Invalidate()
'        End Set
'    End Property
'    Private iControlBackColor As Color = SystemColors.InactiveBorder
'    Public Property ControlBackColor As Color
'        Get
'            Return Me.iControlBackColor
'        End Get
'        Set(value As Color)
'            Me.iControlBackColor = value
'            Me.Invalidate()
'        End Set
'    End Property

'    Private iHeaderHeight As Integer = 20
'    Public Property HeaderHeight As Integer
'        Get
'            Return Me.iHeaderHeight
'        End Get
'        Set(value As Integer)
'            Me.iHeaderHeight = value
'            Me.iHeader_Panel.Size = New Size(Me.Size.Width, Me.iHeaderHeight)
'            Me.Invalidate()
'        End Set
'    End Property
'    Private iHeaderFont As Font = New Font(Me.Font, FontStyle.Bold)
'    Public Property HeaderFont As Font
'        Get
'            Return Me.iHeaderFont
'        End Get
'        Set(value As Font)
'            Me.iHeaderFont = value
'            Me.iHeader_Panel.Invalidate()
'        End Set
'    End Property
'    Private iHeaderBackColorNormal As Color = SystemColors.Menu
'    Public Property HeaderBackColorNormal As Color
'        Get
'            Return Me.iHeaderBackColorNormal
'        End Get
'        Set(value As Color)
'            Me.iHeaderBackColorNormal = value
'        End Set
'    End Property
'    Private iHeaderBackColorHover As Color = SystemColors.Info
'    Public Property HeaderBackColorHover As Color
'        Get
'            Return Me.iHeaderBackColorHover
'        End Get
'        Set(value As Color)
'            Me.iHeaderBackColorHover = value
'        End Set
'    End Property
'    Private iHeaderMouseOver As Boolean = False
'    Public ReadOnly Property HeaderMouseOver As Boolean
'        Get
'            Return Me.iHeaderMouseOver
'        End Get
'    End Property
'    Private iHeaderText As String
'    Public Property HeaderText As String
'        Get
'            If Me.iHeaderText = "" Then
'                Me.iHeaderText = Me.Name
'                Me.iHeader_Panel.Invalidate()
'                Return Me.iHeaderText
'            Else
'                Return Me.iHeaderText
'            End If
'        End Get
'        Set(value As String)
'            Me.iHeaderText = value
'            Me.iHeader_Panel.Invalidate()
'            RaiseEvent HeaderTextChanged(Me, New EventArgs)
'        End Set
'    End Property

'    Public Event HeaderTextChanged(sender As DDPanel, e As System.EventArgs)

'#End Region

'#Region "Constructors"
'    Public Sub New()

'        ' This call is required by the designer.
'        InitializeComponent()

'        ' Add any initialization after the InitializeComponent() call.
'        Me.SetStyle(Windows.Forms.ControlStyles.SupportsTransparentBackColor _
'                    Or Windows.Forms.ControlStyles.OptimizedDoubleBuffer _
'                    Or Windows.Forms.ControlStyles.ResizeRedraw _
'                    Or Windows.Forms.ControlStyles.UserMouse, True)

'        AddupMyControls()
'        Me.iHeaderText = Me.Name
'    End Sub
'    Public Sub New(ContainerCollection As DDPanelCollection, _
'                   ContainerPanel As DDPanelStack, _
'                   HeaderText As String)
'        Me.New()
'        Me.iContainerCollection = ContainerCollection
'        Me.iContainerPanel = ContainerPanel
'        Me.iHeaderText = HeaderText
'    End Sub
'#End Region

'#Region "Overrides"
'    'Main Panel
'    Protected Overrides Sub OnPaintBackground(e As System.Windows.Forms.PaintEventArgs)

'        e.Graphics.Clear(iContainerBackColor)

'    End Sub
'    Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)

'        MyBase.OnPaint(e)

'        If (Me.Width > (Me.iHeaderHeight - 1)) AndAlso (Me.Height > (Me.iHeaderHeight - 1)) Then
'            'create the offline bitmap
'            Dim offBitmap As New Bitmap(Me.ClientRectangle.Width, Me.ClientRectangle.Height)
'            Dim g As Graphics = Graphics.FromImage(offBitmap)

'            g.SmoothingMode = SmoothingMode.AntiAlias

'            'Clear background
'            g.FillRectangle(New SolidBrush(Me.iContainerBackColor), Me.ClientRectangle)

'            'Create path
'            Dim p As New Pen(SystemBrushes.ControlDark)
'            Dim gh As New GraphicsHelper
'            Dim rect As New Rectangle(Me.ClientRectangle.X, _
'                                      Me.ClientRectangle.Y, _
'                                      Me.ClientRectangle.Width - 1, _
'                                      Me.ClientRectangle.Height - 1)
'            Dim gp As GraphicsPath = gh.GetRoundCornerPathForRectangle(rect)

'            'Fill background
'            g.FillPath(New SolidBrush(Me.iControlBackColor), gp)

'            'Draw border
'            g.DrawPath(p, gp)

'            'Now paint off the offline bitmap
'            e.Graphics.DrawImage(offBitmap, Me.ClientRectangle)
'        End If

'    End Sub
'    Protected Overrides Sub OnResize(eventargs As System.EventArgs)

'        'make sure my stuff locates and sizes correctly
'        Me.iHeader_Panel.Location = New Point(0, 0)
'        Me.iHeader_Panel.Size = New Size(Me.Size.Width, Me.iHeaderHeight)
'        Me.iHeader_Panel.Invalidate()

'        Me.iContents_Panel.Location = New Point(2, Me.iHeaderHeight + 1)
'        Me.iContents_Panel.Size = New Size(Me.Size.Width - 4, Me.Size.Height - Me.iHeaderHeight - 3)
'        Me.iContents_Panel.Invalidate()

'        'set fetch expandable height
'        If Me.iExpanding = False AndAlso Me.iCollapsing = False Then
'            Me.iExpandedHeight = Me.Height
'        End If

'        'process base events
'        MyBase.OnResize(eventargs)

'    End Sub
'    Protected Overrides Sub OnControlAdded(e As System.Windows.Forms.ControlEventArgs)
'        MyBase.OnControlAdded(e)
'        'If (e.Control IsNot Me.iHeader_Panel) _
'        '    OrElse (e.Control IsNot Me.iContents_Panel) _
'        '    OrElse (e.Control IsNot Me) Then
'        '    Me.Controls.Remove(e.Control)
'        '    Me.iContents_Panel.Controls.Add(e.Control)
'        'End If

'    End Sub

'    'Header panel
'    Private Sub iHeader_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles iHeader_Panel.Paint

'        If (Me.Width > (Me.iHeaderHeight - 1)) AndAlso (Me.Height > (Me.iHeaderHeight - 1)) Then

'            'create the offline bitmap
'            Dim offBitmap As New Bitmap(Me.ClientRectangle.Width, Me.ClientRectangle.Height)
'            Dim g As Graphics = Graphics.FromImage(offBitmap)

'            g.SmoothingMode = SmoothingMode.AntiAlias

'            'Clear background
'            g.FillRectangle(New SolidBrush(Me.iContainerBackColor), Me.iHeader_Panel.ClientRectangle)

'            'Create path
'            Dim p As New Pen(SystemBrushes.ControlDark)
'            Dim gh As New GraphicsHelper
'            Dim rect As New Rectangle(Me.iHeader_Panel.ClientRectangle.X, _
'                                      Me.iHeader_Panel.ClientRectangle.Y, _
'                                      Me.iHeader_Panel.ClientRectangle.Width - 1, _
'                                      Me.iHeader_Panel.ClientRectangle.Height - 1)
'            Dim gp As GraphicsPath = gh.GetRoundCornerPathForRectangle(rect)

'            'Fill background
'            If (Me.iHeaderMouseOver = True) AndAlso (Me.iExpandOnClick = True) Then
'                g.FillPath(New SolidBrush(Me.iHeaderBackColorHover), gp)
'            Else
'                g.FillPath(New SolidBrush(Me.iHeaderBackColorNormal), gp)
'            End If

'            'Draw border
'            g.DrawPath(p, gp)

'            'Draw icon
'            If Me.iExpandOnClick Then
'                Dim excolIcon As Image = Nothing
'                If Me.iExpanded Then
'                    If Me.iIconCollapse IsNot Nothing Then
'                        excolIcon = Me.iIconCollapse
'                    Else
'                        excolIcon = My.Resources.Icon_Down_Normal
'                    End If
'                Else
'                    If Me.iIconExpand IsNot Nothing Then
'                        excolIcon = Me.iIconExpand
'                    Else
'                        excolIcon = My.Resources.Icon_Up_Normal
'                    End If
'                End If
'                Dim xcRect As New Rectangle(Me.iHeader_Panel.ClientRectangle.Right - Me.iHeader_Panel.ClientRectangle.Height - 4, _
'                                             Me.iHeader_Panel.ClientRectangle.Top + 2, _
'                                             Me.iHeader_Panel.ClientRectangle.Height - 4, _
'                                             Me.iHeader_Panel.ClientRectangle.Height - 4)
'                g.DrawImage(excolIcon, xcRect)
'            End If

'            'Draw text
'            Dim sf As New StringFormat
'            sf.Alignment = StringAlignment.Center
'            sf.LineAlignment = StringAlignment.Center
'            g.DrawString(Me.iHeaderText, iHeaderFont, Brushes.Black, Me.iHeader_Panel.ClientRectangle, sf)

'            'Now paint off the offline bitmap
'            e.Graphics.DrawImage(offBitmap, Me.ClientRectangle)

'        End If

'    End Sub
'    Private Sub iHeader_MouseEnter(sender As Object, e As System.EventArgs) Handles iHeader_Panel.MouseEnter
'        If Me.iHeaderMouseOver = False Then
'            Me.iHeaderMouseOver = True
'            Me.iHeader_Panel.Invalidate()
'        End If
'    End Sub
'    Private Sub iHeader_MouseLeave(sender As Object, e As System.EventArgs) Handles iHeader_Panel.MouseLeave
'        If Me.iHeaderMouseOver = True Then
'            Me.iHeaderMouseOver = False
'            Me.iHeader_Panel.Invalidate()
'        End If
'    End Sub
'    Private Sub iHeader_Click(sender As Object, e As System.EventArgs) Handles iHeader_Panel.Click
'        If Me.iExpandOnClick Then
'            If Me.iExpanded Then
'                Me.iExpanded = False
'                Me.iHeader_Panel.Invalidate()
'                Me.Collapse()
'            Else
'                Me.iExpanded = True
'                Me.iHeader_Panel.Invalidate()
'                Me.Expand()
'            End If
'        End If
'    End Sub
'#End Region

'#Region "Private Procedures"
'    Private Sub Expand()
'        Me.iExpanding = True

'        If Me.iContainerPanel IsNot Nothing Then
'            Me.iContainerPanel.SuspendLayout()
'        End If

'        While (Me.Size.Height < (Me.iExpandedHeight - Me.iHeaderHeight))
'            Me.Size = New Size(Me.Size.Width, Me.Size.Height + Me.iAnimationSteps)
'            Application.DoEvents()
'            Threading.Thread.Sleep(Me.iAnimationDelay)
'        End While
'        Me.Size = New Size(Me.Size.Width, Me.iExpandedHeight)
'        Application.DoEvents()

'        If Me.iContainerPanel IsNot Nothing Then
'            Me.iContainerPanel.ResumeLayout()
'        End If

'        Me.AutoScroll = True
'        Me.iExpanded = True
'        Me.iExpanding = False
'    End Sub
'    Private Sub Collapse()
'        Me.iCollapsing = True
'        Me.AutoScroll = False

'        While (Me.Size.Height > (Me.iHeaderHeight))
'            Me.Size = New Size(Me.Size.Width, Me.Size.Height - Me.iAnimationSteps)
'            Application.DoEvents()
'            Threading.Thread.Sleep(Me.iAnimationDelay)
'        End While
'        Me.Size = New Size(Me.Size.Width, Me.iHeaderHeight)
'        Application.DoEvents()

'        Me.iExpanded = False
'        Me.iCollapsing = False
'    End Sub
'    Private Sub AddupMyControls()
'        Me.SuspendLayout()
'        '
'        'header_Panel
'        '
'        Me.iHeader_Panel.Name = "header_Panel"
'        Me.iHeader_Panel.BackColor = SystemColors.Menu
'        Me.iHeader_Panel.Location = New Point(0, 0)
'        Me.iHeader_Panel.Size = New Size(Me.Size.Width, Me.iHeaderHeight)
'        Me.iHeader_Panel.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
'        Me.Controls.Add(iHeader_Panel)
'        '
'        'contents_Panel
'        '
'        Me.iContents_Panel.Name = "contents_Panel"
'        Me.iContents_Panel.BackColor = Me.iControlBackColor
'        Me.iContents_Panel.BorderStyle = Windows.Forms.BorderStyle.FixedSingle
'        Me.iContents_Panel.Location = New Point(2, Me.iHeaderHeight + 1)
'        Me.iContents_Panel.Size = New Size(Me.Size.Width - 4, Me.Size.Height - Me.iHeaderHeight - 3)
'        Me.iContents_Panel.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top _
'                                       Or System.Windows.Forms.AnchorStyles.Left) _
'                                       Or System.Windows.Forms.AnchorStyles.Right) _
'                                       Or System.Windows.Forms.AnchorStyles.Bottom),  _
'                                  System.Windows.Forms.AnchorStyles)
'        Me.Controls.Add(iContents_Panel)

'        Me.ResumeLayout(False)
'    End Sub
'#End Region


'End Class

'#End Region
